# #Lagos download script
#LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())
#Load in lagos
lagos <- lagosne_load()
## Warning in (function (version = NULL, fpath = NA) : LAGOSNE version unspecified,
## loading version: 1.087.3
#Grab the lake centroid info
lake_centers <- lagos$locus
#Look at the column names
#names(lake_centers)
#Look at the structure
#str(lake_centers)
#View the full dataset
#View(lake_centers %>% slice(1:100))
spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
crs=4326) %>%
st_transform(2163)
#Subset for plotting
subset_spatial <- spatial_lakes %>%
slice(1:100)
subset_baser <- spatial_lakes[1:100,]
#Dynamic mapviewer
mapview(subset_spatial)
states <- us_states()
#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
filter(name == 'Minnesota') %>%
st_transform(2163)
#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]
#Plotting the first 1000 lakes
minnesota_lakes %>%
arrange(-lake_area_ha) %>%
slice(1:1000) %>%
mapview(.,zcol = 'lake_area_ha')
#mapview(states)
Icombined <- states %>%
filter(name %in% c('Illinois', 'Iowa')) %>%
st_transform(2163)
I_lakes <- spatial_lakes[Icombined,]
#Iowa
Iowa <- states %>%
filter(name == 'Iowa') %>%
st_transform(2163)
#Illinois
Illinois <- states %>%
filter(name == 'Illinois') %>%
st_transform(2163)
#rbind states
IA_IL<-rbind(Iowa,Illinois)
mapview(IA_IL)
illinois_lakes <- spatial_lakes[Illinois,]
iowa_lakes <- spatial_lakes[Iowa,]
#rbind lake data
IA_IL2<-rbind(iowa_lakes, illinois_lakes)
#count
str(IA_IL2$lagoslakeid)
## int [1:16466] 4280 4285 4292 4312 4314 4322 4351 4363 4389 4393 ...
str(minnesota_lakes$lagoslakeid)
## int [1:29038] 59 60 61 62 63 64 67 68 71 72 ...
There are about twice as many lakes in Minnesota, 29038, as there are in Iowa and Illinois combined, 16466.
ggplot(iowa_lakes, aes(x=lake_area_ha))+
geom_histogram()+
scale_x_log10()+
labs(title = "Iowa",
x="log(lake area(ha))")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(minnesota_lakes, aes(x=lake_area_ha))+
geom_histogram()+
scale_x_log10()+
labs(title = "Minnesota",
x="log(lake area (ha))")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
There are more larger lakes in Minnesota than in Iowa where the lakes are much smaller.
I_lakes %>%
arrange(-lake_area_ha) %>%
slice(1:1000) %>%
mapview(.,zcol = 'lake_area_ha')
Using information such as the perimeter or the lake and lake depth would give another source of data to compare the sizes of the lakes.